package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcNursingShiftChangeMapper;
import com.csun.cmny.provider.model.domain.OmcNursingShiftChange;
import com.csun.cmny.provider.model.domain.OmcNursingShiftChangeRecord;
import com.csun.cmny.provider.model.dto.nursingShiftChangeRecord.NursingShiftChangeRecordSelectDto;
import com.csun.cmny.provider.model.dto.nursingShiftChangeRecord.NursingShiftChangeSelectDto;
import com.csun.cmny.provider.model.vo.nursingShiftChangeRecord.NursingShiftChangeRecordVo;
import com.csun.cmny.provider.model.vo.nursingShiftChangeRecord.NursingShiftChangeVo;
import com.csun.cmny.provider.service.OmcNursingShiftChangeRecordService;
import com.csun.cmny.provider.service.OmcNursingShiftChangeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
@Transactional
public class OmcNursingShiftChangeServiceImpl extends BaseService<OmcNursingShiftChange> implements OmcNursingShiftChangeService {

    @Resource
    private OmcNursingShiftChangeMapper nursingShiftChangeMapper;

    @Resource
    private OmcNursingShiftChangeRecordService recordService;

    @Override
    public List<NursingShiftChangeVo> selectShiftChangeRecord(NursingShiftChangeSelectDto nursingShiftChangeSelectDto) {
        List<NursingShiftChangeVo> nursingShiftChangeVos = nursingShiftChangeMapper.selectShiftChangeRecord(nursingShiftChangeSelectDto);

        for (NursingShiftChangeVo nursingShiftChangeVo : nursingShiftChangeVos) {
            NursingShiftChangeRecordSelectDto nursingShiftChangeRecordSelectDto = new NursingShiftChangeRecordSelectDto();
            nursingShiftChangeRecordSelectDto.setShiftChangeId(nursingShiftChangeVo.getId());
            List<NursingShiftChangeRecordVo> nursingShiftChangeRecordVos = recordService.selectRecord(nursingShiftChangeRecordSelectDto);
            nursingShiftChangeVo.setRecordVos(nursingShiftChangeRecordVos);
        }

        return nursingShiftChangeVos;
    }
}
